﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using WebNext.Domain;
using WebNext.Domain.Entities;

namespace WebNext.UI.Utils.Validators
{
	public class PasswordValidator : IValidator
	{
		private string password;

		public PasswordValidator(string password)
		{
			this.password = password;
		}

		public virtual ValidationResult Validate()
		{
			ValidationResult result = new ValidationResult();

			if (string.IsNullOrWhiteSpace(this.password))
			{
				result.AddError(Properties.Resources.PasswordCannotBeEmpty);
			}
			else if (this.password.Length < AdminSettings.MinPasswordLength)
			{
				result.AddError(Properties.Resources.PasswordTooShort, AdminSettings.MinPasswordLength);
			}
			else if (this.password.Length > AdminSettings.MaxPasswordLength)
			{
				result.AddError(Properties.Resources.PasswordTooLong, AdminSettings.MaxPasswordLength);
			}
						
			return result;
		}
	}
}